﻿using MongdbHelper;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using WorkDataEs.WorkDataElasticSearchs.Contents.Dto;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            var momgo = new MongoDBHelper("Content");
            //var momgo = new MongoDBHelper("CshiUser");
            var client = momgo.client;
            using (var session = client.StartSession())
            {
                try
                {
                    //session.StartTransaction(new TransactionOptions(readConcern: ReadConcern.Snapshot, writeConcern: WriteConcern.WMajority));//开启事务
                    var list = new List<Content>();
                    //for (int i = 0; i < 1000000; i++)
                    //{
                    //    list.Add(new Content
                    //    {
                    //        Key = i.ToString(),
                    //        Title = i + "康尔 KingCamp 碳纤维登山杖 碳素手杖 户外徒步 轻 外锁KA4665",
                    //        ImgUrl = "https://m.360buyimg.com/babel/jfs/t7699/154/4235664957/46882/ab720071/5a082a42N0f424779.jpg",
                    //        Code = "2495868",
                    //        UnitPrice = 199.0M,
                    //        BaseType = "JdBulkindustrial",
                    //        ClassificationName = "登山攀岩",
                    //        ClassificationCode = ",1,1862,1917,1930,",
                    //        BrandFirstLetters = "K",
                    //        Brand = "康尔（KingCamp）",
                    //        BelongMemberName = "成都京东世纪贸易有限公司",
                    //        IsSelfSupport = 0,
                    //        ResourceStatus = 1,
                    //        BrandGroupBy = "康尔（KingCamp）&K",
                    //        ClassificationGroupBy = "登山攀岩&,1,1862,1917,1930,"
                    //    });
                    //}
                    Stopwatch sb = new Stopwatch();
                    sb.Start();
                    var outTotalPage = 0;
                    var totalCount = 0;
                    var d= momgo.GetPageList<Content>(1, 100000, out outTotalPage, out totalCount, x => true, x => x.Key).ToList();
                    //momgo.InsertMany(list);
                    //session.CommitTransaction();
                    sb.Stop();
                    Console.WriteLine(sb.ElapsedMilliseconds+d.Count());
                    Console.Read();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    //session.AbortTransaction();
                }
            }
            Console.ReadLine();
        }


    }
}
